import JSEncrypt from "./jsencryptWechat.js"

// 密钥对生成 http://web.chacuo.net/netrsakeypair

// const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD\n' +
//   '2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ=='

const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIAL+hq01CMqgbYIKN2Qe70\n' +
  'LzW9BsrEgaGDInhBLTOicMezhGpfQUjcDMklhhJRrV9iQDc6YWbaG3FgIhfA2hAcCAwEAAQ=='

// 加密
export function encrypt (txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}

// 解密
export function decrypt (txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey()
  return encryptor.decrypt(txt)
}
